package com.kingviker.example.bytebuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class ByteBufTest0 {
    public static void main(String[] args) {

        ByteBuf buffer = Unpooled.buffer(10);

        for (int i = 0; i < buffer.capacity(); i++) {
            //相对方法,在当前writerIndex写入i并且writerIndex加一
            buffer.writeByte(i);
        }
        for (int i = 0; i < buffer.capacity(); i++) {
            //绝对方法,不会改变readerIndex
            System.out.println(buffer.getByte(i));
        }
        for (int i = 0; i < buffer.capacity(); i++) {
            //相对方法,读取当前readerIndex的字节并且readerIndexx加一
            System.out.println(buffer.readByte());
        }
    }
}
